import { defineStore } from "pinia";

export const requestStore = defineStore("request", () => {
  const cancelReqList = ref([]);
  const addCancelReq = (cancel: any) => {
    const maxCancelTokenNum = 15; // 最大存cancelToken条数
    if (cancelReqList.value.length >= maxCancelTokenNum) {
      cancelReqList.value.shift();
    }
    cancelReqList.value.push(cancel);
    console.log("cancelReqList", cancelReqList.value);
  };
  const removeCancelReq = (index: any) => {
    cancelReqList.value.splice(index, 1);
    console.log("cancelReqList", cancelReqList.value);
  };
  return { cancelReqList, addCancelReq, removeCancelReq };
});
